{template header}
<div id="mainFrame">
	<div class="order-tab-bar">
    	<div class="item{if $type=='goods'} on{/if}"><a href="/?m=$G[m]&c=$G[c]&type=goods">商品</a></div>
        <div class="item{if $type=='shop'} on{/if}"><a href="/?m=$G[m]&c=$G[c]&type=shop">店铺</a></div>
    </div>
    <div class="blank"></div>
    {if $favoritelist}
	<form method="post" autocomplete="off" id="favForm">
    <input type="hidden" name="formsubmit" value="yes">
    <input type="hidden" name="formhash" value="{FORMHASH}">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="fav-table">
      <thead>
      <tr>
      	<th width="20"></th>
        <th width="80"></th>
        <th>{if $type=='goods'}商品{else}店铺{/if}</th>
        <th width="140">收藏时间</th>
        <th width="100">操作</th>
      </tr>
      </thead>
      <tbody>
      {loop $favoritelist $flist}
      <tr class="row" id="row_$flist[favid]">
        <td><input type="checkbox" value="{$flist[favid]}" name="delete[]"></td>
        <td><div class="pic">
        	{if $type=='goods'}
        	<a href="/?m=goods&c=detail&id=$flist[dataid]" target="_blank"><img src="{echo image($flist[image])}"></a>
            {else}
            <a href="/?m=shop&c=detail&shopid=$flist[dataid]" target="_blank"><img src="{echo image($flist[image])}"></a>
            {/if}
        </div></td>
        <td class="title">
        	{if $type=='goods'}
            <a href="/?m=goods&c=detail&id=$flist[dataid]" target="_blank">$flist[title]</a>
            {else}
            <a href="/?m=shop&c=detail&shopid=$flist[dataid]" target="_blank">$flist[title]</a>
            {/if}
        </td>
        <td>{echo @date('Y-m-d H:i:s', $flist[dateline])}</td>
        <td><a onclick="removeItem($flist[favid])">取消收藏</a></td>
      </tr>
      {/loop}
      </tbody>
      <tfoot>
      <tr>
        <td colspan="10">
           <div class="pages">{$pages}</div>
           <label><input type="checkbox" class="checkbox" onclick="DSXCMS.checkAll(this,'delete[]')"> 全选</label>&nbsp;&nbsp;
           <input type="submit" class="button submit" id="removeBtn" value="删除">
        </td>
      </tr>
      </tfoot>
    </table>
    </form>
    {else}
    <div style="text-align:center; font-size:14px; display:block; margin-top:30px;">你的收藏夹没有信息</div>
    {/if}
</div>
<script type="text/javascript">
function removeItem(favid){
	if(confirm('你确定要删除吗?')){
		$.ajax({
			url:'/?m=$G[m]&c=$G[c]&a=remove&favid='+favid,
			dataType:"json",
			success: function(json){
				if(json && json.errno === 0){
					$("#row_"+favid).remove();
					if($(".row").length == 0) {
						window.location.reload();
					}
				}else {
				}
			}	
		});
	}
}

$("#favForm").submit(function(e) {
    return confirm('你确定要从收藏夹移除选中项目吗');
});
</script>
{template footer}